home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
cmsnt100.zip
/
CMSNOTES.BAS
next >
Wrap
BASIC Source File
|
1992-07-23
|
18KB
|
707 lines
' Process CMS NOTEBOOK files
'
' Allows reading of each note in file
' Allows replying to notes, regular mode
' Allows replying to notes, TEXT mode
' Allows sending notes
'
DECLARE SUB AllDone ()
DECLARE SUB BuildIndex ()
DECLARE SUB HdrItems ()
DECLARE SUB HdrNote ()
DECLARE SUB HelpItems ()
DECLARE SUB HelpNote ()
DECLARE SUB Pause ()
DECLARE SUB ReadIndex ()
DECLARE SUB ReadNote (note)
DECLARE SUB SetUp ()
DECLARE SUB ShowFiles ()
DECLARE SUB ShowItems ()
DECLARE SUB ShowNote (note)
DECLARE SUB Display (file, pointer(), items%, first%, last%)
DECLARE FUNCTION ConvertDate (adate$)
DECLARE FUNCTION Modtime$ (atime$)
DECLARE FUNCTION Word$ (aline$, num)
COMMON SHARED dirnote$, dirndx$, indexsize%, notesize%
COMMON SHARED fsize, title$, version$, dircmd$
COMMON SHARED pitems(), pnote()
COMMON SHARED infile$, outfile$, note$(), note, notecount%
title$ = "CMS Notebook processor "
version$ = "v1r0m0"
PRINT ""
PRINT ""
PRINT title$ + version$
SetUp
ShowFiles
ShowItems
AllDone
END
'
' Close the .NOT and .IDX files
'
SUB AllDone
CLS
CLOSE #1
CLOSE #2
SHELL "del cmsnote.dir"
END SUB
'
' Build an index of the selected .NOT file
'
SUB BuildIndex
' 12345678.123 nnnnnnnn mm-dd-yy hh:mm nnnnnnn nnnnnnn nnn.nn%
PRINT " %";
LOCATE CSRLIN, 1
PRINT dirnote$;
' ....+....1....+....2....+....3....+....4....+....5....+....6....+....7
LINE INPUT #1, aline$
notecount% = 0
notestart = 1
lines = 0
OPEN outfile$ FOR OUTPUT AS #2
WRITE #2, " 0", 0, 0
DO
lines = lines + 1
IF LEFT$(aline$, 72) = STRING$(72, "=") THEN
IF notecount% > 0 THEN
notelines% = notelines% - 1
size$ = RIGHT$(" " + STR$(notelines%), 5)
item$ = from$ + " " + ndate$ + " " + size$ + " " + subj$
FOR z = 1 TO LEN(item$)
IF MID$(item$, z, 1) = CHR$(34) THEN
MID$(item$, z, 1) = "'"
END IF
NEXT z
WRITE #2, item$, notestart, notelines%
END IF
needhdr$ = "Y"
notelines% = 0
notecount% = notecount% + 1
LOCATE CSRLIN, 41
PRINT RIGHT$(" " + STR$(notecount%), 7);
LOCATE CSRLIN, 50
PRINT RIGHT$(" " + STR$(lines), 7);
LOCATE CSRLIN, 59
PRINT USING "###.##%"; (notestart / fsize) * 100;
notestart = SEEK(1)
ELSE
IF needhdr$ = "Y" THEN
Work$ = Word$(UCASE$(aline$), 1)
SELECT CASE Work$
CASE "FROM:"
from$ = LTRIM$(MID$(aline$, 7))
from$ = LEFT$(from$ + SPACE$(19), 19)
CASE "DATE:"
ndate$ = LTRIM$(MID$(aline$, 7))
ndate$ = LEFT$(ndate$ + SPACE$(14), 14)
CASE "SUBJECT:"
subj$ = LTRIM$(MID$(aline$, 10))
CASE ""
needhdr$ = "N"
END SELECT
END IF
END IF
notelines% = notelines% + 1
LINE INPUT #1, aline$
LOOP WHILE NOT (EOF(1))
LOCATE CSRLIN, 41
PRINT RIGHT$(" " + STR$(notecount%), 7);
LOCATE CSRLIN, 50
PRINT RIGHT$(" " + STR$(lines), 7);
LOCATE CSRLIN, 59
PRINT "100.00%"
notelines% = notelines% - 1
size$ = RIGHT$(" " + STR$(notelines%), 5)
item$ = from$ + " " + ndate$ + " " + size$ + " " + subj$
FOR z = 1 TO LEN(item$)
IF MID$(item$, z, 1) = CHR$(34) THEN
MID$(item$, z, 1) = "'"
END IF
NEXT z
WRITE #2, item$, notestart, notelines%
SEEK #2, 1
WRITE #2, LEFT$(STR$(notecount%) + SPACE$(5), 5), 0, 0
CLOSE #2
END SUB
'
' To convert a date string of mm/dd/yy into a numeric of yymmdd
'
FUNCTION ConvertDate (adate$)
adate$ = RIGHT$("0" + adate$, 8)
am$ = LEFT$(adate$, 2)
ad$ = MID$(adate$, 4, 2)
ay$ = RIGHT$(adate$, 2)
ConvertDate = VAL(ay$ + am$ + ad$)
END FUNCTION
'
' to display either a item or note screen
'
SUB Display (file, pointer(), items%, first%, last%)
' LOCATE 2, 1
' PRINT file, pointer(first%), items%, first%, last%
IF file = 1 THEN
LOCATE 3, 1
ELSE
LOCATE 4, 1
END IF
FOR z% = first% TO last%
IF z% > items% THEN
EXIT FOR
END IF
SEEK file, pointer(z%)
IF file = 1 THEN
LINE INPUT #file, line$
PRINT LEFT$(line$ + SPACE$(80), 80)
ELSE
INPUT #file, items$, start, lines%
PRINT RIGHT$(SPACE$(5) + STR$(z%), 5) + " " + LEFT$(items$ + SPACE$(33), 73)
END IF
NEXT z%
DO WHILE CSRLIN < 24
PRINT SPACE$(80)
LOOP
END SUB
'
' Print headers for ShowItems
'
SUB HdrItems
CLS
PRINT title$ + version$
LOCATE 1, 40
PRINT infile$
LOCATE 1, 67
PRINT "Items: " + STR$(notecount%)
LOCATE 3, 1
PRINT " # From: Date: Size: Subject:"
' PRINT "1234 1234567890123456789 12345678901234 1234 12345678901234567890123456789"
LOCATE 24, 1
PRINT "Up & Down arrow keys, PgUp & PgDn";
LOCATE 24, 40
PRINT "Bottom Help Quit Read Top";
END SUB
'
' Print headers for ReadNote
'
SUB HdrNote
CLS
PRINT title$ + version$
LOCATE 1, 40
PRINT "Note: " + STR$(note)
LOCATE 1, 67
PRINT "Lines: " + STR$(notesize%)
LOCATE 24, 1
PRINT "Up & Down arrow keys, PgUp & PgDn";
LOCATE 24, 40
PRINT "Bottom Help Next Prev Quit Top";
END SUB
'
' Give help for the Items screen
'
SUB HelpItems
CLS
PRINT "Help for items screen"
PRINT ""
PRINT "Here is where you view the index of notes"
PRINT ""
PRINT "You can scroll through the list with the arrow keys and the"
PRINT "PageUp and PageDown keys"
PRINT ""
PRINT "You read a note with the R key and leave this program with Q"
DO
LOOP WHILE INKEY$ = ""
END SUB
'
' Give help for the Items screen
'
SUB HelpNote
CLS
PRINT "Help for note screen"
PRINT ""
PRINT "Here is where you view the note"
PRINT ""
PRINT "You can scroll through the note with the arrow keys and the"
PRINT "PageUp and PageDown keys"
PRINT ""
PRINT "You read the next note with the N key, see the previous with P"
PRINT "and leave this program with Q"
DO
LOOP WHILE INKEY$ = ""
END SUB
'
' to take a hh:mmx time and return a 24 hour time as hh:mm
'
FUNCTION Modtime$ (atime$)
ind$ = RIGHT$(atime$, 1)
IF ind$ = "P" THEN
IF LEFT$(atime$, 2) <> "12" THEN
MID$(atime$, 1, 2) = LTRIM$(STR$(VAL(LEFT$(atime$, 2)) + 12))
END IF
END IF
IF ind$ = "P" OR ind$ = "A" THEN
atime$ = LEFT$(atime$, LEN(atime$) - 1)
END IF
Modtime$ = RIGHT$(atime$, 5)
END FUNCTION
'
' to pause the display
'
SUB Pause
PRINT ""
PRINT ""
PRINT "Press a key to continue"
DO
LOOP UNTIL INKEY$ <> ""
END SUB
'
' To read in an existing .NDX file
'
SUB ReadIndex
' 12345678.123 nnnnnnnn mm-dd-yy hh:mm nnnnnnn nnnnnnn nnn.nn%
PRINT " ";
LOCATE CSRLIN, 1
PRINT dirndx$;
' ....+....1....+....2....+....3....+....4....+....5....+....6....+....7
OPEN outfile$ FOR INPUT AS #2
INPUT #2, size$, start, lines
size% = VAL(size$)
DIM pitems(size%)
lines = 0
FOR z% = 1 TO size%
pitems(z%) = SEEK(2)
INPUT #2, items$, start, lines%
lines = lines + lines% + 1
LOCATE CSRLIN, 41
PRINT RIGHT$(" " + STR$(z%), 7);
LOCATE CSRLIN, 50
PRINT RIGHT$(" " + STR$(lines), 7);
LOCATE CSRLIN, 59
PRINT USING "###.##%"; (z% / size%) * 100;
IF EOF(2) THEN
EXIT FOR
END IF
NEXT z%
LOCATE CSRLIN, 41
PRINT RIGHT$(" " + STR$(z%), 7);
LOCATE CSRLIN, 50
PRINT RIGHT$(" " + STR$(lines), 7);
LOCATE CSRLIN, 59
PRINT "100.00%"
notecount% = z%
indexsize